﻿
IF object_id(N'dbo.[UDS_Flow_Step]', 'U') IS NULL
BEGIN
    CREATE TABLE [dbo].[UDS_Flow_Step] (
        [Flow_ID]       int           NOT NULL,
        [Step_ID]       int           NOT NULL,
        [Step_Name]     nvarchar(300) COLLATE Chinese_PRC_CI_AS NOT NULL,
        [Step_Remark]   nvarchar(max) COLLATE Chinese_PRC_CI_AS NULL,
        [RightToFinish] bit           NOT NULL,
        [Flow_Rule]     int           NOT NULL, /* 0: Staff; 1: Position; 2: Project */
        [PassNum]       int           NOT NULL,
        [LocalAlert]    bit           NOT NULL CONSTRAINT [DF_UDS_Flow_Step_LocalAlert] default((0)),
        [BaseHour]      int           NOT NULL CONSTRAINT [DF_UDS_Flow_Step_BaseHour] default((0)),
        [CycTimes]      int           NOT NULL CONSTRAINT [DF_UDS_Flow_Step_CycTimes] default((0)),
        [Period]        int           NOT NULL CONSTRAINT [DF_UDS_Flow_Step_Period] default((0)),

        CONSTRAINT [PK_UDS_Flow_Step] PRIMARY KEY CLUSTERED (Flow_ID asc, Step_ID asc),
        CONSTRAINT [FK_UDS_Flow_Step_Flow_ID] FOREIGN KEY (Flow_ID) REFERENCES dbo.UDS_Flow(Flow_ID) ON DELETE CASCADE
    );
END
GO
